<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form  action="login" method="post">
    <label for="">用户名</label>
    <input type="text" name="userName" id="userName">
    <label for="">密码</label>
    <input type="password" name="pwd" id="pwd">
    <label for="">3天免登录</label>
    <input type="checkbox" id="Keep_record" name="Keep_record" value="ok">
    <button type="submit">登录</button>
</form>

</body>
</html>
<script>
      //获得浏览器中的cookie
      let str= document.cookie;
      //判断是否有cookie
     if(str!=''){
           let datas=str.split(";");
           let name = datas[0].split("=")[1];
           let pwd = datas[1].split("=")[1];
           console.log(name+"   "+pwd);
           document.getElementById("userName").value=name;
         document.getElementById("userName").type="password";
           document.getElementById("pwd").value=pwd;
           document.getElementById("Keep_record").checed=true;
         //提交表单
          //document.forms[0].submit();

     }

</script>